#include "PipelineStates.h"

namespace devii
{

PipelineStates::PipelineStates()
{
	rasterizer = 0;
	blend = 0;
}

PipelineStates::~PipelineStates()
{
	if(rasterizer)
		rasterizer->Release();
	if(blend)
		blend->Release();

	for(unsigned int i = 0; i < sampler_states.size(); i++)
	{
		if(sampler_states[i])
			sampler_states[i]->Release();
	}
}


void PipelineStates::pushSamplerState(ID3D11SamplerState* const sampler)
{
	sampler_states.push_back(sampler);
}

const unsigned int PipelineStates::getSamplerSize() const
{
	return sampler_states.size();
}

void PipelineStates::setRasterizerState(ID3D11RasterizerState* const rasterizer)
{
	this->rasterizer = rasterizer;
}


void PipelineStates::setBlendState(ID3D11BlendState* const blend)
{
	this->blend = blend;
}

ID3D11SamplerState*const* PipelineStates::getSamplerState() const
{
	return &sampler_states[0];
}

ID3D11RasterizerState* PipelineStates::getRasterizerState() const
{
	return rasterizer;
}

ID3D11BlendState* PipelineStates::getBlendState() const
{
	return blend;
}


void PipelineStates::setBlendFactor(float blend_factor[])
{
	this->blend_factor[0] = blend_factor[0];
	this->blend_factor[1] = blend_factor[1];
	this->blend_factor[2] = blend_factor[2];
	this->blend_factor[3] = blend_factor[3];
}

void PipelineStates::setSamplemask(const unsigned int samplemask)
{
	this->samplemask = samplemask;
}


float* PipelineStates::getBlendFactor()
{
	return &blend_factor[0];
}

unsigned int PipelineStates::getSamplemask()
{
	return samplemask;
}

}